home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / gnome-vfs-2.0 / libgnomevfs / gnome-vfs-xfer.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-05-01  |  10.6 KB  |  295 lines

  1. /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
  2.  
  3. /* gnome-vfs-xfer.h - File transfers in the GNOME Virtual File System.
  4.  
  5.    Copyright (C) 1999 Free Software Foundation
  6.  
  7.    The Gnome Library is free software; you can redistribute it and/or
  8.    modify it under the terms of the GNU Library General Public License as
  9.    published by the Free Software Foundation; either version 2 of the
  10.    License, or (at your option) any later version.
  11.  
  12.    The Gnome Library is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.    Library General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU Library General Public
  18.    License along with the Gnome Library; see the file COPYING.LIB.  If not,
  19.    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20.    Boston, MA 02111-1307, USA.
  21.  
  22.    Author: Ettore Perazzoli <ettore@comm2000.it> */
  23.  
  24. #ifndef GNOME_VFS_XFER_H
  25. #define GNOME_VFS_XFER_H
  26.  
  27. #include <libgnomevfs/gnome-vfs-file-info.h>
  28.  
  29. G_BEGIN_DECLS
  30.  
  31. /* Xfer options.  
  32.  * FIXME bugzilla.eazel.com 1205:
  33.  * Split these up into xfer options and xfer actions
  34.  */
  35. typedef enum {
  36.     GNOME_VFS_XFER_DEFAULT = 0,
  37.     GNOME_VFS_XFER_UNUSED_1 = 1 << 0,
  38.     GNOME_VFS_XFER_FOLLOW_LINKS = 1 << 1,
  39.     GNOME_VFS_XFER_UNUSED_2 = 1 << 2,
  40.     GNOME_VFS_XFER_RECURSIVE = 1 << 3,
  41.     GNOME_VFS_XFER_SAMEFS = 1 << 4,
  42.     GNOME_VFS_XFER_DELETE_ITEMS = 1 << 5,
  43.     GNOME_VFS_XFER_EMPTY_DIRECTORIES = 1 << 6,
  44.     GNOME_VFS_XFER_NEW_UNIQUE_DIRECTORY = 1 << 7,
  45.     GNOME_VFS_XFER_REMOVESOURCE = 1 << 8,
  46.     GNOME_VFS_XFER_USE_UNIQUE_NAMES = 1 << 9,
  47.     GNOME_VFS_XFER_LINK_ITEMS = 1 << 10,
  48.     GNOME_VFS_XFER_FOLLOW_LINKS_RECURSIVE = 1 << 11,
  49.     GNOME_VFS_XFER_TARGET_DEFAULT_PERMS = 1 << 12
  50. } GnomeVFSXferOptions;
  51.  
  52. /* Progress status, to be reported to the caller of the transfer operation.  */
  53. typedef enum {
  54.     GNOME_VFS_XFER_PROGRESS_STATUS_OK = 0,
  55.     GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR = 1,
  56.     GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE = 2,
  57.     /* during the duplicate status the progress callback is asked to
  58.        supply a new unique name */
  59.     GNOME_VFS_XFER_PROGRESS_STATUS_DUPLICATE = 3
  60. } GnomeVFSXferProgressStatus;
  61.  
  62. /* The different ways to deal with overwriting during a transfer operation.  */
  63. typedef enum {
  64.     /* Interrupt transferring with an error (GNOME_VFS_ERROR_FILEEXISTS).  */
  65.     GNOME_VFS_XFER_OVERWRITE_MODE_ABORT = 0,
  66.     /* Invoke the progress callback with a
  67.        `GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE' status code. */
  68.     GNOME_VFS_XFER_OVERWRITE_MODE_QUERY = 1,
  69.     /* Overwrite files silently.  */
  70.     GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE = 2,
  71.     /* Ignore files silently.  */
  72.     GNOME_VFS_XFER_OVERWRITE_MODE_SKIP = 3
  73. } GnomeVFSXferOverwriteMode;
  74.  
  75. /**
  76.  * GnomeVFSXferOverwriteAction:
  77.  * @GNOME_VFS_XFER_OVERWRITE_ACTION_ABORT: abort the transfer
  78.  * @GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE: replace the existing file
  79.  * @GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE_ALL: replace the existing file, and all future files
  80.  * without prompting the callback.
  81.  * @GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP: don't copy over the existing file
  82.  * @GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP_ALL: don't copy over the existing file, and all future
  83.  * files without prompting the callback.
  84.  * 
  85.  * This defines the actions to perform before a file is being overwritten
  86.  * (i.e., these are the answers that can be given to a replace query).  
  87.  **/
  88. typedef enum {
  89.     GNOME_VFS_XFER_OVERWRITE_ACTION_ABORT = 0,
  90.     GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE = 1,
  91.     GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE_ALL = 2,
  92.     GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP = 3,
  93.     GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP_ALL = 4
  94. } GnomeVFSXferOverwriteAction;
  95.  
  96. typedef enum {
  97.     /* Interrupt transferring with an error (code returned is code of the
  98.            operation that has caused the error).  */
  99.     GNOME_VFS_XFER_ERROR_MODE_ABORT = 0,
  100.     /* Invoke the progress callback with a
  101.        `GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR' status code. */
  102.     GNOME_VFS_XFER_ERROR_MODE_QUERY = 1
  103. } GnomeVFSXferErrorMode;
  104.  
  105. /* This defines the possible actions to be performed after an error has
  106.    occurred.  */
  107. typedef enum {
  108.     /* Interrupt operation and return `GNOME_VFS_ERROR_INTERRUPTED'.  */
  109.     GNOME_VFS_XFER_ERROR_ACTION_ABORT = 0,
  110.     /* Try the same operation again.  */
  111.     GNOME_VFS_XFER_ERROR_ACTION_RETRY = 1,
  112.     /* Skip this file and continue normally.  */
  113.     GNOME_VFS_XFER_ERROR_ACTION_SKIP = 2
  114. } GnomeVFSXferErrorAction;
  115.  
  116. /* This specifies the current phase in the transfer operation.  Phases whose
  117.    comments are marked with `(*)' are always reported in "normal" (i.e. no
  118.    error) condition; the other ones are only reported if an error happens in
  119.    that specific phase.  */
  120. typedef enum {
  121.     /* Initial phase */
  122.     GNOME_VFS_XFER_PHASE_INITIAL,
  123.     /* Checking if destination can handle move/copy */
  124.     GNOME_VFS_XFER_CHECKING_DESTINATION,
  125.     /* Collecting file list */
  126.     GNOME_VFS_XFER_PHASE_COLLECTING,
  127.     /* File list collected (*) */
  128.     GNOME_VFS_XFER_PHASE_READYTOGO,
  129.     /* Opening source file for reading */
  130.     GNOME_VFS_XFER_PHASE_OPENSOURCE,
  131.     /* Creating target file for copy */
  132.     GNOME_VFS_XFER_PHASE_OPENTARGET,
  133.     /* Copying data from source to target (*) */
  134.     GNOME_VFS_XFER_PHASE_COPYING,
  135.     /* Moving file from source to target (*) */
  136.     GNOME_VFS_XFER_PHASE_MOVING,
  137.     /* Reading data from source file */
  138.     GNOME_VFS_XFER_PHASE_READSOURCE,
  139.     /* Writing data to target file */
  140.     GNOME_VFS_XFER_PHASE_WRITETARGET,
  141.     /* Closing source file */
  142.     GNOME_VFS_XFER_PHASE_CLOSESOURCE,
  143.     /* Closing target file */
  144.     GNOME_VFS_XFER_PHASE_CLOSETARGET,
  145.     /* Deleting source file */
  146.     GNOME_VFS_XFER_PHASE_DELETESOURCE,
  147.     /* Setting attributes on target file */
  148.     GNOME_VFS_XFER_PHASE_SETATTRIBUTES,
  149.     /* Go to the next file (*) */
  150.     GNOME_VFS_XFER_PHASE_FILECOMPLETED,
  151.     /* cleaning up after a move (removing source files, etc.) */
  152.     GNOME_VFS_XFER_PHASE_CLEANUP,
  153.     /* Operation finished (*) */
  154.     GNOME_VFS_XFER_PHASE_COMPLETED,
  155.     GNOME_VFS_XFER_NUM_PHASES
  156. } GnomeVFSXferPhase;
  157.  
  158. /* Progress information for the transfer operation.  This is especially useful
  159.    for interactive programs.  */
  160. typedef struct {
  161.     /* Progress status (see above for a description).  */
  162.     GnomeVFSXferProgressStatus status;
  163.  
  164.     /* VFS status code.  If `status' is
  165.            `GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR', you should look at this
  166.            member to know what has happened.  */
  167.     GnomeVFSResult vfs_status;
  168.  
  169.     /* Current phase in the transferring process.  */
  170.     GnomeVFSXferPhase phase;
  171.  
  172.     /* Source URI. FIXME bugzilla.eazel.com 1206: change name? */
  173.     gchar *source_name;
  174.  
  175.     /* Destination URI. FIXME bugzilla.eazel.com 1206: change name? */
  176.     gchar *target_name;
  177.  
  178.     /* Index of file being copied. */
  179.     gulong file_index;
  180.  
  181.     /* Total number of files to be copied.  */
  182.     gulong files_total;
  183.  
  184.     /* Total number of bytes to be copied.  */
  185.     GnomeVFSFileSize bytes_total;
  186.  
  187.     /* Total size of this file (in bytes).  */
  188.     GnomeVFSFileSize file_size;
  189.  
  190.     /* Bytes copied for this file so far.  */
  191.     GnomeVFSFileSize bytes_copied;
  192.  
  193.     /* Total amount of data copied from the beginning.  */
  194.     GnomeVFSFileSize total_bytes_copied;
  195.     
  196.     /* Target unique name used when duplicating, etc. to avoid collisions */ 
  197.     gchar *duplicate_name;
  198.  
  199.     /* Count used in the unique name e.g. (copy 2), etc. */
  200.     int duplicate_count;
  201.  
  202.     gboolean top_level_item;
  203.     /* indicates that the copied/moved/deleted item is an actual item
  204.      * passed in the uri list rather than one encountered by recursively
  205.      * traversing directories. Used by metadata copying.
  206.      */
  207.  
  208.     /* Reserved for future expansions to GnomeVFSXferProgressInfo
  209.      * without having to break ABI compatibility */
  210.     void *reserved1;
  211.     void *reserved2;
  212.  
  213. } GnomeVFSXferProgressInfo;
  214.  
  215. /* This is the prototype for functions called during a transfer operation to
  216.    report progress.  If the return value is `FALSE' (0), the operation is
  217.    interrupted immediately: the transfer function returns with the value of
  218.    `vfs_status' if it is different from `GNOME_VFS_OK', or with
  219.    `GNOME_VFS_ERROR_INTERRUPTED' otherwise.  The effect of other values depend
  220.    on the value of `info->status':
  221.  
  222.    - If the status is `GNOME_VFS_XFER_PROGRESS_STATUS_OK', the transfer
  223.      operation is resumed normally.
  224.  
  225.    - If the status is `GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR', the return
  226.      value is interpreted as a `GnomeVFSXferErrorAction' and operation is
  227.      interrupted, continued or retried accordingly.
  228.  
  229.    - If the status is `GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE', the return
  230.      value is interpreted as a `GnomeVFSXferOverwriteAction'.  */
  231.  
  232. typedef gint (* GnomeVFSXferProgressCallback)     (GnomeVFSXferProgressInfo *info,
  233.                          gpointer data);
  234.  
  235. typedef struct GnomeVFSProgressCallbackState {
  236.  
  237.     /* xfer state */
  238.     GnomeVFSXferProgressInfo *progress_info;    
  239.  
  240.     /* Callback called for every xfer operation. For async calls called 
  241.        in async xfer context. */
  242.     GnomeVFSXferProgressCallback sync_callback;
  243.  
  244.     /* Callback called periodically every few hundred miliseconds
  245.        and whenever user interaction is needed. For async calls
  246.        called in the context of the async call caller. */
  247.     GnomeVFSXferProgressCallback update_callback;
  248.  
  249.     /* User data passed to sync_callback. */
  250.     gpointer user_data;
  251.  
  252.     /* Async job state passed to the update callback. */
  253.     gpointer async_job_data;
  254.  
  255.     /* When will update_callback be called next. */
  256.     gint64 next_update_callback_time;
  257.  
  258.     /* When will update_callback be called next. */
  259.     gint64 next_text_update_callback_time;
  260.  
  261.     /* Period at which the update_callback will be called. */
  262.     gint64 update_callback_period;
  263.  
  264.  
  265.     /* Reserved for future expansions to GnomeVFSProgressCallbackState
  266.      * without having to break ABI compatibility */
  267.     void *reserved1;
  268.     void *reserved2;
  269.  
  270. } GnomeVFSProgressCallbackState;
  271.  
  272. GnomeVFSResult gnome_vfs_xfer_uri_list    (const GList                  *source_uri_list,
  273.                        const GList                  *target_uri_list,
  274.                        GnomeVFSXferOptions           xfer_options,
  275.                        GnomeVFSXferErrorMode         error_mode,
  276.                        GnomeVFSXferOverwriteMode     overwrite_mode,
  277.                        GnomeVFSXferProgressCallback  progress_callback,
  278.                        gpointer                      data);
  279. GnomeVFSResult gnome_vfs_xfer_uri         (const GnomeVFSURI            *source_uri,
  280.                        const GnomeVFSURI            *target_uri,
  281.                        GnomeVFSXferOptions           xfer_options,
  282.                        GnomeVFSXferErrorMode         error_mode,
  283.                        GnomeVFSXferOverwriteMode     overwrite_mode,
  284.                        GnomeVFSXferProgressCallback  progress_callback,
  285.                        gpointer                      data);
  286. GnomeVFSResult gnome_vfs_xfer_delete_list (const GList                  *source_uri_list,
  287.                        GnomeVFSXferErrorMode         error_mode,
  288.                        GnomeVFSXferOptions           xfer_options,
  289.                        GnomeVFSXferProgressCallback  progress_callback,
  290.                        gpointer                      data);
  291.  
  292. G_END_DECLS
  293.  
  294. #endif /* GNOME_VFS_XFER_H */
  295.